package com.gdpu.project.util;

import java.util.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class DateUtil1 {

	/**
	 * date转换成String
	 */
	public static String dateToString(Date date) {
		SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
		if (date != null) {
			return s.format(date);
		}
		return null;
	}

	/**
	 * String转换成date
	 */
	public static Date stringToDate(String date) {
		SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
		Date dDate = null;
		try {
			dDate = (Date) s.parse(date);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		if (date != null) {
			return dDate;
		}
		return null;
	}
}
